package org.maverickjs.application;

import java.util.ArrayList;
import java.util.List;

public class MessageRepository {

	private static MessageRepository messageRepository;
	private List<String> messages;

	private MessageRepository() {
		this.messages = new ArrayList<>();
	}

	public static MessageRepository getInstance() {

		if (messageRepository == null) 
			messageRepository = new MessageRepository();
		
		return messageRepository;
	}
	
	public void addMessage(String message) {
		this.messages.add(message);
	}
	
	public String getMessage() {
		
		if (messages.size() > 0)
			this.messages.get(this.messages.size()-1);
		else
			return "";
		
		return null;
	}
	

}